package com.dl.mall.utils.result;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/***
 * 错误码和错误信息定义
 * 1. 错误码定义规则为5位数字
 * 2. 前两位表示业务场景，最后三位表示错误码。例如：100001。10:通用 001:系统未知异常
 * 错误码列表：
 *  10: 通用
 *      001：参数格式校验
 *  11: 用户
 *  12: 商品
 *  13: 订单
 *  ...
 */
@Getter
@ToString
public enum ResultCodeEnum {

    /*登录注册类*/
    SUCCESS(true, 200, "成功"),

    SUCCESS_LOGIN(true,200,"登陆成功!"),
    ACCOUNT_lockout(false,400,"账号锁定，请联系管理员解锁！"),
    ACCOUNT_ERROR(false,400,"账户或密码错误！"),
    CAPTCHA_ERROR(false,400,"验证码错误！！"),


    SUCCESS_REGISTER(true,20000,"注册成功!"),

    /*token*/
    TOKENS_SIGNATURE_EXCEPTION(false, 403, "token签名异常"),
    TOKENS_EXPIRE_EXCEPTION(false, 403, "token过期异常"),
    TOKENS_MISMATCH_EXCEPTION(false, 403, "token算法不匹配异常"),
    TOKENS_INVALID_EXCEPTION(false, 403, "token无效"),

    UNKNOWN_REASON(false,20001,"未知错误"),
    BAD_SQL_GRAMMAR(false,21001,"sql语法错误"),
    JSON_PARSE_ERROR(false,21002,"json解析异常"),
    PARAM_ERROR(false,21003,"参数不正确"),
    FILE_UPLOAD_ERROR(false,21004,"文件上传错误"),
    EXCEL_DATA_IMPORT_ERROR(false,21005,"Excel数据导入错误"),
    ERROR_AUTH_CODE(false,21006,"验证码错误!"),
    ERROR_NOT_EXISTS_USER(false,21007,"用户不存在!"),
    ERROR_PASSWORD(false,21008,"密码错误,请重新输入!");


    private final Boolean success;

    private final Integer code;

    private final String message;

    ResultCodeEnum(Boolean success, Integer code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;
    }
}

